<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const pm = new Promise((resolve, reject) => {
            console.log("获取数据");
            try {
                setTimeout(() => {
                    console.log("请求成功");
                    resolve({
                        token: "rain"
                    })
                }, 2000)
            }catch(e){
                reject(e.message)
            }
            
        })

        console.log("pm",pm);
        // pm成功状态触发
        pm.then(value=>{

        })
        //pm失败状态触发
        const p2 = pm.catch(reason=>{

        })

        console.log("p2",p2);//返回值与pm一致???

    </script>
</body>

</html>